﻿// =================================================================== 
// 项目说明
//====================================================================
// lsc。@Copy Right 2019
// 文件： CallEnd.cs
// 项目名称：斑马车务
// 创建时间：2020-02-13
// 负责人：lsc
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using Dapper.Extensions;
using CRM.Infrastructure.Entity;
using CRM.Infrastructure.Repository;
namespace CRM.Infrastructure.Service
{
	
	/// <summary>
	///
	/// </summary>
	public class CallEndService
	{
         protected CallEndRepository repository;
         
         public  CallEndService(){
           repository = new CallEndRepository();         
         }
         
        #region 增删改查

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(CallEnd entity) { return repository.Insert(entity); }

        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public object Insert(List<CallEnd> entitys) { return repository.Insert(entitys); }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Update(CallEnd entity) { return repository.Update(entity); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        public bool Delete(CallEnd entity) { return repository.Delete(entity); }

        /// <summary>
        /// 删除所有
        /// </summary>
        /// <returns></returns>
        public bool DeleteAll() { return repository.DeleteAll(); }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public bool Delete(int primaryKey) { return repository.Delete(primaryKey); }

        /// <summary>
        /// 查询单个实体
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public CallEnd SingleOrDefault(object primaryKey) { return repository.SingleOrDefault(primaryKey); }

       
        /// <summary>
        /// 查询单个实体,如果存在多条则引发异常
        /// </summary>
        /// <param name="primaryKey">主键</param>
        /// <returns></returns>
        public CallEnd Single(object primaryKey) { return repository.Single(primaryKey); }

        /// <summary>
        /// 查询所有
        /// </summary>
        /// <returns></returns>
        public List<CallEnd> QueryAll()
        {
            return repository.QueryAll();
        }

        #endregion

	    /// <summary>
	    /// 根据用户传参ID返回对应的录音文件下载地址
	    /// </summary>
	    /// <param name="companyId"></param>
	    /// <param name="subID"></param>
	    /// <returns></returns>
	    public List<CallEnd> GetCallEndInfoBySubID(int companyId,string subID)
        {
            return repository.GetCallEndInfoBySubID(companyId,subID);
        }


        /// <summary>
        /// 根据线索获取通话详情
        /// </summary>
        /// <param name="clueId"></param>
        /// <returns></returns>
        public List<CallEnd> GetCallEndsByClue(int clueId)
        {
            return repository.GetCallEndsByClue(clueId);
        }
    }
	
}